<?php
namespace Admin\Controller;
use Think\Controller;
class ImgController extends CommonController {
  public function index(){
      $this->filesnames = scandir(__ROOT__.'Public/img/');
      $this->display();
  }
  public function upload(){
    $config = array(
        'maxSize'    =>    3145728,
        'rootPath'   =>    './Public/img/',
        'savePath'   =>    '',
        'saveName'   =>    array('date','Ymdhis'),
        'autoSub'    =>    false,
    );
    $upload = new \Think\Upload($config);// 实例化上传类\
     // 上传文件
     $info   =   $upload->upload();
     if(!$info) {// 上传错误提示错误信息
         $this->error($upload->getError());die();
     }else $this->success("上传成功");
  }

  public function del(){
    unlink(__ROOT__.'Public/img/'.I('get.name').'.'.I('get.type'));
    $this->success("删除成功");
  }
}
